package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @version V1.0
 * @package todo
 * @description:
 * @author: wangdi
 * @date: 2019/7/25 9:46
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Reference
    private UserService userService;

    @RequestMapping("/getMenuList")
    public Result getMenuList(String username) {
        try {
            List<Map> menuList = userService.getMenuList(username);
            return new Result(true, MessageConstant.GET_MENU_SUCCESS, menuList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_MENU_FAIL);
        }
    }
}
